<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>更新店铺信息</title>
		<script type="text/javascript" src="/admin/qrcode/jq.js"></script>
		<script type="text/javascript" src="/admin/qrcode/bot.js"></script>
		<link rel="stylesheet" type="text/css" href="/admin/css/boot.css"></link>
		<link rel="stylesheet" type="text/css" href="/admin/css/sl.css"></link>
		<style>
			label span{color: #ff0000; padding-right: 5px;}
		</style>
	</head>

	<body>
	<h2>修改店铺信息</h2>
	<form id="myForm" class="form-horizontal">
		<div class="form-group">
			<label class="col-sm-1 control-label"><span>*</span>账号</label>
			<div class="col-sm-9">
				<input required="required" name="spencerUser" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label"><span>*</span>密码</label>
			<div class="col-sm-9">
				<input required="" name="spencerWord" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label"><span>*</span>店铺名称</label>
			<div class="col-sm-9">
				<input name="spencerName" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label"><span>*</span>地址</label>
			<div class="col-sm-9">
				<input name="location" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label"><span>*</span>老板姓名</label>
			<div class="col-sm-9">
				<input name="userName" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label"><span>*</span>手机号</label>
			<div class="col-sm-9">
				<input name="phone" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label">创建时间</label>
			<div class="col-sm-9">
				<input name="createTime" class="form-control"/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-1 control-label"></label>
			<div class="col-sm-9">
				<button id="btnUpdate" type="button" class="btn btn-sm btn-info">提&nbsp;交</button>
				<button type="reset"  class="btn btn-sm btn-warning">重&nbsp;置</button>
			</div>
		</div>
		</form>		
	</body>
</html>
<script>

	$(function () {
		queryById();
		//提交按钮的单击事件--实现真正的更新
		$("#btnUpdate").click(function () {
			$.ajax({
				type: "POST",//这里必须写POST
				url: "/Spencer/spencer",
				data: $("#myForm").serialize()+"&_method=PUT",
				dataType:"json",
				success: function(vo){
					if(vo.code===200) {
						window.location.href = "list.html";
					}else{
						alert("更新失败！"+vo.msg);
					}
				}
			});
		});
	});
	function queryById() {
		$.ajax({
			type: "POST",
			url: "/Spencer/selectKeySpencer", //RESTful风格的API定义
			data: "",
			success: function (vo) {
				let obj=vo;
				let teamLogo=obj.spencerUser;
				let teamName=obj.spencerWord;
				let chineseName=obj.spencerName;
				let coach=obj.location;
				let stadium=obj.userName;
				let location=obj.phone;
				let time=obj.state;
				let engine=obj.createTime;
				let power=obj.picture;
				//let area=obj.picture;
				$("input[name='spencerUser']").val(teamLogo);
				$("input[name='spencerWord']").val(teamName);
				$("input[name='spencerName']").val(chineseName);
				$("input[name='location']").val(coach);
				$("input[name='userName']").val(stadium);
				$("input[name='phone']").val(location);
				$("input[name='createTime']").val(engine);

				//$("select[name='picture']").val(area);
				/*if(area!=null){
					$("img[name='teamLogo']").attr("src","/img/uploadFile/"+teamLogo);
				}else{
					$("img[name='teamLogo']").addClass("hidden");
					$("img[name='teamLogo']").parent().html("还没有上传logo图片");
				}*/
			}
		});
	}

</script>